package util;

import org.springframework.beans.factory.FactoryBean;

import java.lang.reflect.Proxy;

/**
 * Created by chenyipu on 2017/9/7.
 */
public class MyFactoryBean implements FactoryBean {
    Object realObject;
    public MyFactoryBean(Object obj){
        realObject = obj;
    }

    public Object getObject() throws Exception {
        return Proxy.newProxyInstance(realObject.getClass().getClassLoader(),realObject.getClass().getInterfaces(),new MyInvocationHandler(realObject));
    }

    public Class<?> getObjectType() {
        return realObject.getClass();
    }

    public boolean isSingleton() {
        return false;
    }
}
